<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <button>点击</button>
    <div></div>
    <script>
        var btn = document.querySelector('button');
        var div = document.querySelector('div');
        btn.addEventListener('click', function() {
            var time = 5;
            setInterval(function() {
                if (time == 0) {
                    location.href = 'http://www.itcast.cn'
                }
                div.innerHTML = '您将在' + time + '秒后跳转';
                time--;
            }, 1000);
        })
    </script>
</body>

</html>